package com.winchain.chainbill.bill.biz.receive.rx;

import com.shell.framework.rx.OnErrorNotImplementedSubscriber;
import com.winchain.chainbill.ChainBillUtil;
import com.winchain.chainbill.bill.base.po.CbRcv;
import com.winchain.chainbill.bill.base.po.CbRec;
import com.winchain.chainbill.bill.biz.receive.vo.BillRcv;
import com.winchain.chainbill.bill.biz.send.rx.BatchBillEvent;
import com.winchain.chainbill.esign.service.BatchSignService;
import com.winchain.chainbill.esign.vo.BatchSignVo;
import java.util.ArrayList;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class BillRcvAprvSignSubscriber extends OnErrorNotImplementedSubscriber<BatchBillEvent<BillRcv, CbRcv>> {
	@Autowired
	private BatchSignService batchSignService;
	private static final String REASON = "������������";

	public void onApplicationEvent(BatchBillEvent<BillRcv, CbRcv> t) {
		if (!ChainBillUtil.signContOnline()) {
			return;
		}
		String phoneCode = t.getStringValue("phoneCode");
		String location = t.getStringValue("location");

		List<String> signBillIds = new ArrayList();
		List<BillRcv> records = t.getRecs();
		for (BillRcv record : records) {
			signBillIds.add(record.getRec().getBillId());
		}
		BatchSignVo batchSignVo = new BatchSignVo();
		batchSignVo.setSignBillIds(signBillIds);
		batchSignVo.setBizType("10");
		batchSignVo.setPhoneCode(phoneCode);
		batchSignVo.setLocation(location);
		batchSignVo.setReason("������������");
		this.batchSignService.batchSign(batchSignVo);
	}
}
